﻿using System.Reflection;
using System.Windows;

namespace 抽象工厂模式
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            //// 南昌工厂制作南昌的鸭脖
            //var nanChangFactory =new NanChangFactory();
            //var nanChangYabo = nanChangFactory.CreateYaBo();
            //nanChangYabo.Print();
            //// 上海工厂制作上海的鸭脖
            //var shangHaiFactory = new ShangHaiFactory();
            //shangHaiFactory.CreateYaBo().Print();

            //Assembly反射取得工厂对象
            var typeFactory = "No1";
            var nanChangFactory = (AbstractFactory) Assembly.Load("抽象工厂模式").CreateInstance("抽象工厂模式." + typeFactory);
            var nanChangYabo = nanChangFactory?.CreateYaBo();
            nanChangYabo?.Print();
        }
    }
}
